<?PHP 
function side_block_regional_show(){

	global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig;

		//GET MOD CONFIG STUFF
		if (!isset($GLOBALS['xoopsModuleConfig']) || $GLOBALS['xoopsModule']->getVar('dirname') != "local_news") {
		  $modhandler = &xoops_gethandler('module');
		  $module = &$modhandler->getByDirname("local_news");
		  $config_handler = &xoops_gethandler('config');
		  $xoopsModuleConfig = &$config_handler->getConfigsByCat(0,$module->getVar('mid')); 
		  $enableSyndication = $xoopsModuleConfig['enableSyndication'];
		  $inModule = 0;
		}else {
		  $enableSyndication = $xoopsModuleConfig['enableSyndication'];
		  $inModule = 1;
		}
		//END GET MOD CONFIG STUFF
		
	
	//GET SYNDICATED NEWS STORIES 
	if($enableSyndication == 1){
	
	 
			$link = mysql_connect($xoopsModuleConfig['syndicationDB_Host'], $xoopsModuleConfig['syndicationDB_User'], $xoopsModuleConfig['syndicationDB_Passaword']) or ($error = mysql_error());
			$Query = "SELECT * FROM CA_SE_News WHERE storyID NOT LIKE '".strtoupper($xoopsModuleConfig['stationLetters'])."%' AND expiration_date > '".mktime()."' AND publish_date < '".mktime(23,59,59,date("m"),date("d"),date("Y"))."' AND soundfile != '' ORDER BY publish_date DESC,ID DESC LIMIT ".$xoopsModuleConfig['NISR']."";
			mysql_select_db($xoopsModuleConfig['syndicationDB']) or ($error = "Could not select database");
			  $result = mysql_query ($Query, $link) or ($error = "Query failed");
	
		if ($result){
		    $syndication = array();			
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
			$syndication['headline'][] = $row['headline'];
			$syndication['ID'][] = $row['ID'];
			$syndication['storyID'][] = $row['storyID'];
			}
			mysql_free_result($result);
			mysql_close ($link);
			
			if(count($syndication['headline']) > 0){
				$tempSyndication=array();
				for($i=0; $i < count($syndication['storyID']); $i++){
					$tempSyndication[] = array("headline"=>$syndication['headline'][$i],"ID"=>$syndication['ID'][$i],"storyID"=>$syndication['storyID'][$i]);
				}
				$syndication = $tempSyndication;
				//return the bugger
				$all = array("data2" => $syndication,"inModule" => $inModule);
				return $all;
			}else{
			return false;
			}
	
					
		}else{
			return false;
		}//end $result if
			
		  
	}else{
		return false;
	}//end syndication if
	


	
}//end function

?>